const chat = {
  chatE: document.getElementById('chat'),
  chatOutputE: document.getElementById('chat-output'),
  chatInputE: document.getElementById('chat-input'),
  output(name, color, content) {
    const e = document.createElement('div')
    e.innerHTML = '<b class="chat-output-name"></b><span></span>'
    e.children[0].innerText = name
    e.children[0].style.color = color
    e.children[1].innerText = content
    chat.chatOutputE.appendChild(e)
    chat.chatOutputE.scrollTo(0, chat.chatOutputE.scrollHeight)
  },
  submit() {
    if (_.send && chat.chatInputE.value.length) {
      _.send({ type: 'chat', content: chat.chatInputE.value })
      chat.chatInputE.value = ''
    }
  },
  toggle() {
    if (chat.chatE.style.bottom) {
      chat.chatE.style.bottom = ''
    } else {
      chat.chatE.style.bottom = '-254px'
    }
  }
}
